package ValidPerfectSquare;

public class Solution {
    public boolean isPerfectSquare(int num) {
        if (num==1) return true;
    	int left=1,right=num/2;
        while (right>=left){
        	long mid=(right+left)/2;
        	long sqr=mid*mid;
        	if (sqr==num)
        		return true;
        	else if (sqr>num)
        		right=(int) (mid-1);
        	else if (sqr<num)
        		left=(int) (mid+1);
        }
        return false;
    }
    public static void main(String args[]){
    	Solution so=new Solution();
    	System.out.println(so.isPerfectSquare(808201));
    }
}
